<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-11-24
 * Time: 13:42
 */

namespace app\common\model;


use think\Db;
use think\Model;
class SkillInfo extends Model
{

    /**
     * 根据用户ID  获取用户的技能信息
     */
    public static function skillInfoForUid($uid)
    {
        $data  = Db::name('skill_info')->where('si_uid', $uid)->find();
        if ($data) {
            $data['si_application_type'] = Db::name('skill_type')->where('st_id', 'in',  explode(',', $data['si_application_type']))->field('group_concat(st_name) st_name')->select();
            $data['si_project_type']     = Db::name('skill_type')->where('st_id', 'in',  explode(',', $data['si_project_type']))->field('group_concat(st_name) st_name')->select();
            $data['si_deve_language'] = Db::name('skill_type')->where('st_id', 'in',  explode(',', $data['si_deve_language']))->field('group_concat(st_name) st_name')->select();
            $data['si_deve_skill'] = Db::name('skill_type')->where('st_id', 'in', explode(',', $data['si_deve_skill']))->field('group_concat(st_name) st_name')->select();
            $data['si_product'] = Db::name('skill_type')->where('st_id', 'in',  explode(',', $data['si_product']))->field('group_concat(st_name) st_name')->select();
            $data['si_post'] = Db::name('skill_type')->where('st_id', 'in',  explode(',', $data['si_post']))->field('group_concat(st_name) st_name')->select();
        }
        return $data;
    }

    /**
     *根据类型数组  获取类型名称
     */
    public static function getSkillName($arr)
    {
        return Db::name('skill_type')
            ->where('st_id', 'in',  $arr)
            ->field('group_concat(st_name) st_name')->select();
    }
}